package Card;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class CardDemo {

    //购买一副牌
    public static List<Card> buyCard() {
        String[] str = {"♠", "♥", "♣", "♦"};

        List<Card> cardList = new ArrayList<>();

        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < str.length; j++) {
                Card card = new Card(str[j], i);
                cardList.add(card);
            }
        }

        return cardList;

    }


    //打乱牌
    public static void dislocateCard(List<Card> cardList) {

        for (int i = 1; i < cardList.size(); i++) {
            Random random = new Random();

            int val = random.nextInt(i);

            swap(cardList, val, i);

        }

    }

    public static void swap(List<Card> cardList, int i, int j) {
        Card card = cardList.get(i);

        cardList.set(i, cardList.get(j));

        cardList.set(j, card);

    }

    //给三个人发牌
    public static List<List<Card>> Licensing(List<Card> cardList) {
        List<List<Card>> list = new ArrayList<>();

        List<Card> list0 = new ArrayList();
        List<Card> list1 = new ArrayList();
        List<Card> list2 = new ArrayList();

        list.add(list0);
        list.add(list1);
        list.add(list2);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                list.get(j).add(cardList.get(0));
                cardList.remove(0);
            }
        }

        return list;
    }
}
